package cn.com.netedge.iot.frontend.biz.protocol;

import cn.com.netedge.iot.common.dataobject.CmdMsgReq;
import cn.com.netedge.iot.common.dataobject.CmdMsgResp;
import cn.com.netedge.iot.common.dataobject.ReceiveFrame;
import cn.com.netedge.iot.common.exception.BizException;
import cn.com.netedge.iot.common.utils.StringUtil;
import cn.com.netedge.iot.frontend.biz.dao.AchvMeterMapper;
import cn.com.netedge.iot.frontend.biz.vo.DeviceTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ProtocolDlt645_07Handle extends AbstractHandle {
    private static Logger logger = LoggerFactory.getLogger(ProtocolDlt645_07Handle.class);
    @Autowired
    private AchvMeterMapper meterMapper;

    @Override
    public CmdMsgResp decoder(ReceiveFrame frame) throws BizException {
        CmdMsgResp resp = new CmdMsgResp();

        byte[] rawData = frame.getRawData();
        String deviceNumber = frame.getDeviceNumber();
        int deviceType = frame.getDeviceType();
        if(StringUtil.isEmpty(deviceNumber) || deviceType < 0) {
            resp.setMessage("No login frame receive.");
            resp.setSuccess(false);
            return resp;
        }
        String key = deviceNumber + "_" + deviceType;
        byte[] receiveBuf = frame.getReceiveBuffer();
        return resp;
    }

    @Override
    public byte[] encoder(CmdMsgReq req) throws BizException {
        return null;
    }

    @Override
    public void preEncoder(CmdMsgReq req) {

    }

    @Override
    public boolean isTaskMatch(DeviceTask task, CmdMsgResp resp) {
        return true;
    }

}
